﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<TemplateWeb.Models.ViewModels.GroupViewModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <% Sach sach = Model.SachModel.GetModel.LstObjModel[0]; %>
    <div style="float: left; padding-right: 30px; border-right: 1px solid #dcdcd">
        <img id="ContentPlaceHolder1_imgProduct" src="../../Content/Images/Items/<%= sach.SanPham.HinhMinhHoa %>"
            alt="<%= sach.SanPham.TenSanPham %>" width="200" height="260" />
    </div>
    <div class="product_info">
        <h2 class="font_blue_max">
            <%= sach.SanPham.TenSanPham%></h2>
        <p>
            <b>Tác giả: </b>
            <%= sach.TacGia%>
            - <b>Nhà xuất bản: </b>
            <%= sach.NhaXuatBan%></p>
        <div style="margin-top: 15px; width: 480px">
            <div style="float: left; width: 120px; padding: 3px 0;">
                Tình trạng:
            </div>
            <div style="float: left; width: 120px; padding: 3px 0;">
                <%= sach.SanPham.SoLuongTon > 0 ? "Còn hàng" : "Hết hàng" %>
            </div>
            <div style="float: right; width: 120px; padding: 3px 0;">
                <%= sach.SoTrang %>
            </div>
            <div style="float: right; width: 120px; padding: 3px 0;">
                Số trang:
            </div>
            <div style="float: left; width: 120px; padding: 3px 0;">
                Giá bìa:
            </div>
            <div style="float: left; width: 120px; padding: 3px 0;">
                <span class="font_price">
                    <%= string.Format("{0:0,0}", sach.SanPham.GiaBan)%>
                    ₫ </span>
            </div>
            <div style="float: right; width: 120px; padding: 3px 0;">
                <%= string.Format("{0:dd/MM/yyyy}", sach.NgayXuatBan)%>
            </div>
            <div style="float: right; width: 120px; padding: 3px 0;">
                Ngày xuất bản:
            </div>
        </div>
        <div class="clear">
        </div>
        <br />
        <% if (Page.User.Identity.Name == string.Empty)
           { %>
        <a href="<%= Url.Action("AddToCart", "Home", new { id = Model.SachModel.GetModel.LstObjModel[0].ID, idloaisach = Model.SachModel.GetModel.LstObjModel[0].IDLoaiSach })%>">
            <img src="../../../Content/Images/Home/shopNow.png" alt="Shop Now" />
        </a>
        <% }
           else if (Roles.GetRolesForUser(Page.User.Identity.Name)[0].Equals(StringEnum.GetStringValue(LoaiNguoiDung.CUSTOMER)))
           { %>
        <a href="<%= Url.Action("AddToCart", "Home", new { id = Model.SachModel.GetModel.LstObjModel[0].ID, idloaisach = Model.SachModel.GetModel.LstObjModel[0].IDLoaiSach })%>">
            <img src="../../../Content/Images/Home/shopNow.png" alt="Shop Now" />
        </a>
        <% } %>
        <div class="clear">
        </div>
    </div>
    <div class="clear">
    </div>
    <div class="bg_introBook">
        <p>
            Giới thiệu</p>
    </div>
    <div>
        <div class="intro">
            <div>
                <p style="text-align; justify;">
                    <%= sach.NoiDung %>
                </p>
                <p>
                    <strong><span style="font-size: " small=""><span style="font-family: " verdana="">Mời
                        các bạn đón đọc!</span></span></strong></p>
            </div>
            <div class="product_list" style="width: 660px;">
                <div class="clear">
                </div>
            </div>
            <%
                var lstSachCungLoai = Model.AllSachModel.GetModel.LstObjModel.Where(n => n.ID != sach.ID && n.IDLoaiSach == sach.IDLoaiSach).ToList();
                var numRow = lstSachCungLoai.Count % 4 == 0 ? lstSachCungLoai.Count / 4 : (lstSachCungLoai.Count / 4 + 1);
            %>
            <div class="bg_relateProduct">
                <p>
                    Sách cùng loại</p>
            </div>
            <% var ItemIndex = 0;
               for (int i = 0; i < numRow; i++)
               { %>
            <div class="product_list">
                <% for (int j = ItemIndex; j < lstSachCungLoai.Count; j++)
                   { %>
                <div class="prod_item">
                    <center>
                        <a href="<%= Url.Action("ChiTietSach", "Home", new { id = lstSachCungLoai[j].ID }) %>">
                            <img src="../../Content/Images/Items/<%= lstSachCungLoai[j].SanPham.HinhMinhHoa %>"
                                alt="<%= lstSachCungLoai[j].SanPham.TenSanPham %>" width="120" height="160"></a>
                        <p class="prod_name">
                            <a href="<%= Url.Action("ChiTietSach", "Home", new { id = lstSachCungLoai[j].ID }) %>">
                                <%= lstSachCungLoai[j].SanPham.TenSanPham%></a></p>
                        <p class="font_price">
                            Giá bìa:
                            <%= string.Format("{0:0,0}", lstSachCungLoai[j].SanPham.GiaBan)%>
                            ₫</p>
                    </center>
                </div>
                <% ItemIndex++;
                   if (ItemIndex > 0 && ItemIndex % 4 == 0)
                   {
                       break;
                   }
                   } %>
            </div>
            <% } %>
        </div>
        <div class="clear">
        </div>
    </div>
</asp:Content>
